<?php

 include './utils/conn.php';

 //get user inputs
$stu_no=$_POST['stu_no'];
$stu_name=$_POST['stu_name'];
$sex=$_POST['sex'];
$tel=$_POST['tel'];
$major=$_POST['major'];
$class_name=$_POST['class_name'];
$hobby=$_POST['hobby'];

//sql
$sql="update student set stu_name='".$stu_name;
$sql.="', sex='".$sex;
$sql.="', tel='".$tel;
$sql.="', major='".$major;
$sql.="', class_name='".$class_name;
$sql.="', hobby='".$hobby;
$sql.="' where stu_no='".$stu_no."'";

//execute sql

$result=mysqli_query($conn,$sql);
if($result){
    echo json_encode(["code"=>1,"msg"=>"update成功"],JSON_UNESCAPED_UNICODE);
}else{
    echo json_encode(["code"=>0,"msg"=>"update失败"],JSON_UNESCAPED_UNICODE);
}